package phoenics.upservice.entity;

import java.io.Serializable;
import javax.persistence.*;


import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;


/**
 * The persistent class for the project database table.
 * 
 */
@Entity
@Table(name="project")
//@NamedEntityGraph(name = "Project.projectPics",attributeNodes = @NamedAttributeNode("projectPics"))
public class Project implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Long id;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="create_time", insertable = false, updatable = false)
	private Date createTime;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="open_date")
	private Date openDate;

	@Column(name="open_number")
	private int openNumber;

	@Column(name="project_address")
	private String projectAddress;

	@Column(name="project_area")
	private String projectArea;

	@Column(name="project_category")
	private String projectCategory;

	@Lob
	@Column(name="project_detail")
	private String projectDetail;

	@Column(name="project_duties1")
	private String projectDuties1;

	@Column(name="project_duties1_tel")
	private String projectDuties1Tel;

	@Column(name="project_duties2")
	private String projectDuties2;

	@Column(name="project_duties2_tel")
	private String projectDuties2Tel;

	@Column(name="project_duties3")
	private String projectDuties3;

	@Column(name="project_duties3_tel")
	private String projectDuties3Tel;

	@Column(name="project_name")
	private String projectName;

	//bi-directional many-to-one association to User
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="user_id")
	private User user;
	@OneToMany(mappedBy="project",fetch=FetchType.LAZY)
	private List<ProjectPic> projectPics=new ArrayList<>();

	//bi-directional many-to-many association to User
	@ManyToMany(cascade = {CascadeType.ALL},fetch=FetchType.LAZY)
	@JoinTable(
		name="follow_project"
		, joinColumns={
			@JoinColumn(name="project_id")
			}
		, inverseJoinColumns={
			@JoinColumn(name="user_id")
			}
		)
	private Set<User> users=new HashSet<>();

	//bi-directional many-to-one association to UserProject
	@OneToMany(mappedBy="project",fetch=FetchType.LAZY)
	private List<UserProject> userProjects;

	public Project() {
	}

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Date getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getOpenDate() {
		return this.openDate;
	}

	public void setOpenDate(Date openDate) {
		this.openDate = openDate;
	}

	public int getOpenNumber() {
		return this.openNumber;
	}

	public void setOpenNumber(int openNumber) {
		this.openNumber = openNumber;
	}

	public String getProjectAddress() {
		return this.projectAddress;
	}

	public void setProjectAddress(String projectAddress) {
		this.projectAddress = projectAddress;
	}

	public String getProjectArea() {
		return this.projectArea;
	}

	public void setProjectArea(String projectArea) {
		this.projectArea = projectArea;
	}

	public String getProjectCategory() {
		return this.projectCategory;
	}

	public void setProjectCategory(String projectCategory) {
		this.projectCategory = projectCategory;
	}

	public String getProjectDetail() {
		return this.projectDetail;
	}

	public void setProjectDetail(String projectDetail) {
		this.projectDetail = projectDetail;
	}

	public String getProjectDuties1() {
		return this.projectDuties1;
	}

	public void setProjectDuties1(String projectDuties1) {
		this.projectDuties1 = projectDuties1;
	}

	public String getProjectDuties1Tel() {
		return this.projectDuties1Tel;
	}

	public void setProjectDuties1Tel(String projectDuties1Tel) {
		this.projectDuties1Tel = projectDuties1Tel;
	}

	public String getProjectDuties2() {
		return this.projectDuties2;
	}

	public void setProjectDuties2(String projectDuties2) {
		this.projectDuties2 = projectDuties2;
	}

	public String getProjectDuties2Tel() {
		return this.projectDuties2Tel;
	}

	public void setProjectDuties2Tel(String projectDuties2Tel) {
		this.projectDuties2Tel = projectDuties2Tel;
	}

	public String getProjectDuties3() {
		return this.projectDuties3;
	}

	public void setProjectDuties3(String projectDuties3) {
		this.projectDuties3 = projectDuties3;
	}

	public String getProjectDuties3Tel() {
		return this.projectDuties3Tel;
	}

	public void setProjectDuties3Tel(String projectDuties3Tel) {
		this.projectDuties3Tel = projectDuties3Tel;
	}

	public String getProjectName() {
		return this.projectName;
	}

	public void setProjectName(String projectName) {
		this.projectName = projectName;
	}

	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Set<User> getUsers() {
		return this.users;
	}

	public void setUsers(Set<User> users) {
		this.users = users;
	}

	public List<UserProject> getUserProjects() {
		return this.userProjects;
	}

	public void setUserProjects(List<UserProject> userProjects) {
		this.userProjects = userProjects;
	}

	public UserProject addUserProject(UserProject userProject) {
		getUserProjects().add(userProject);
		userProject.setProject(this);

		return userProject;
	}

	public UserProject removeUserProject(UserProject userProject) {
		getUserProjects().remove(userProject);
		userProject.setProject(null);

		return userProject;
	}

	public List<ProjectPic> getProjectPics() {
		return projectPics;
	}

	public void setProjectPics(List<ProjectPic> projectPics) {
		this.projectPics = projectPics;
	}

}